define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        //详细
        index: function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.size() > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");

            Controller.api.bindevent();
        },
        table: {
            // 回访列表
            visit: function () {
                Table.api.init({
                    table: 'business_visit',
                })
                // 表格1
                var table1 = $("#table1");
                table1.bootstrapTable({
                    url: 'business/Highseainfo/visit?ids=' + Fast.api.query('ids'),
                    toolbar: '#toolbar1',
                    sortName: 'visit.createtime',
                    search: false,
                    columns: [
                        [
                            { checkbox: true },
                            { field: 'id', title: __('Id'), sortable: true },
                            { field: 'business.nickname', title: __('Bnickname'), operate: 'LIKE' },
                            { field: 'content', title: __('Vcontent'), operate: 'LIKE' },
                            { field: 'admin.nickname', title: __('Dnickname'), sortable: false, searchable: false },
                            { field: 'createtime', title: __('Screatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', }
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table1);
            },
            // 申请记录
            receive: function () {
                Table.api.init({
                    table: 'business_receive',
                })
                // 表格1
                var table2 = $("#table2");
                table2.bootstrapTable({
                    url: 'business/Highseainfo/receive?ids=' + Fast.api.query('ids'),
                    toolbar: '#toolbar2',
                    sortName: 'applytime',
                    search: false,
                    columns: [
                        [
                            { checkbox: true },
                            { field: 'id', title: __('Id'), sortable: true },
                            { field: 'business.nickname', title: __('Bnickname'), operate: 'LIKE' },
                            { field: 'admin.nickname', title: __('Dnickname'), sortable: false, searchable: false },
                            { field: 'status_text', title: __('VstatusText'), sortable: false, searchable: false },
                            { field: 'applytime', title: __('Rapplytime'), sortable: true, searchable: true, formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', }
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table2);
            }
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"))
            },
        },
    };
    return Controller;
});